import type { SelectProps } from 'antd';
import { Select } from 'antd';
import { useTradeData } from './useTradeData';

export function TradeSelect({
  value,
  disabled,
  placeholder,
  ...props
}: Omit<SelectProps<string, { label: string; value: string }>, 'options'>) {
  const { data, loading } = useTradeData();

  return (
    <Select
      loading={loading}
      value={loading ? undefined : value}
      disabled={disabled || loading}
      options={data}
      placeholder={placeholder ?? '全部'}
      {...props}
    ></Select>
  );
}
